<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title></title>
</head>
<script>
    var txt="<movielist><movie>";
    txt=txt+"<title>阿呆与阿瓜</title>";
    txt=txt+"<star>金•凯瑞</star>";
    txt=txt+"<year>1994</year>";
    txt=txt+"</movie></movielist>";
function get_xml(){
	var xmldoc,moviesNode,movieNode;
	var titleNode,starNode,yearNode,displayText;
    if (window.DOMParser){
        parser=new DOMParser();
        xmldoc=parser.parseFromString(txt,"text/xml");
    }else{ // Internet Explorer
        xmldoc=new ActiveXObject("Microsoft.XMLDOM");
        xmldoc.async=false;
        xmldoc.loadXML(txt);
    }
    moviesNode=xmldoc.documentElement;
    movieNode=moviesNode.firstChild;
    titleNode=movieNode.firstChild;
    starNode=titleNode.nextSibling;
    yearNode=starNode.nextSibling;
	displayText="影片名称："+titleNode.firstChild.nodeValue+'&emsp;主演：'+starNode.firstChild.nodeValue+'&emsp;上映年份：'+yearNode.firstChild.nodeValue;
	div.innerHTML=displayText;
}
</script>
<body>
<input type="button" value="获取影片数据" onClick="get_xml()">
<br>
<br>
<div id="div"></div>
</body>
</html>
